home *** CD-ROM | disk | FTP | other *** search
- head 5.8;
- branch 5.8.0;
- access;
- symbols
- RELEASE:5.8.0.13
- BETA:5.8.0.12
- UICSO:5.8.0
- VANILLA:5.8;
- locks; strict;
- comment @ * @;
-
-
- 5.8
- date 90.06.20.08.35.23; author paul; state Exp;
- branches
- 5.8.0.1;
- next ;
-
- 5.8.0.1
- date 90.10.04.11.19.22; author paul; state Exp;
- branches;
- next 5.8.0.2;
-
- 5.8.0.2
- date 90.10.13.17.45.48; author paul; state Exp;
- branches;
- next 5.8.0.3;
-
- 5.8.0.3
- date 90.11.19.16.14.09; author paul; state Exp;
- branches;
- next 5.8.0.4;
-
- 5.8.0.4
- date 90.11.24.02.38.53; author paul; state Exp;
- branches;
- next 5.8.0.5;
-
- 5.8.0.5
- date 90.11.28.16.40.07; author paul; state Exp;
- branches;
- next 5.8.0.6;
-
- 5.8.0.6
- date 91.01.19.19.26.02; author paul; state Exp;
- branches;
- next 5.8.0.7;
-
- 5.8.0.7
- date 91.02.17.03.42.40; author paul; state Exp;
- branches;
- next 5.8.0.8;
-
- 5.8.0.8
- date 91.03.04.21.48.23; author paul; state Exp;
- branches;
- next 5.8.0.9;
-
- 5.8.0.9
- date 91.04.02.23.08.34; author paul; state Exp;
- branches;
- next 5.8.0.10;
-
- 5.8.0.10
- date 91.04.05.14.55.15; author paul; state Exp;
- branches;
- next 5.8.0.11;
-
- 5.8.0.11
- date 91.05.18.17.20.31; author paul; state Exp;
- branches;
- next 5.8.0.12;
-
- 5.8.0.12
- date 91.05.30.22.11.12; author paul; state Exp;
- branches;
- next 5.8.0.13;
-
- 5.8.0.13
- date 91.06.21.12.36.40; author paul; state Exp;
- branches;
- next ;
-
-
- desc
- @@
-
-
- 5.8
- log
- @5.64 Berkeley release
- @
- text
- @/*
- * Copyright (c) 1983 Eric P. Allman
- * Copyright (c) 1988 Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted provided
- * that: (1) source distributions retain this entire copyright notice and
- * comment, and (2) distributions including binaries display the following
- * acknowledgement: ``This product includes software developed by the
- * University of California, Berkeley and its contributors'' in the
- * documentation or other materials provided with the distribution and in
- * all advertising materials mentioning features or use of this software.
- * Neither the name of the University nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
- #ifndef lint
- static char sccsid[] = "@@(#)clock.c 5.8 (Berkeley) 6/1/90";
- #endif /* not lint */
-
- # include "sendmail.h"
- # include <signal.h>
-
- /*
- ** SETEVENT -- set an event to happen at a specific time.
- **
- ** Events are stored in a sorted list for fast processing.
- ** An event only applies to the process that set it.
- **
- ** Parameters:
- ** intvl -- intvl until next event occurs.
- ** func -- function to call on event.
- ** arg -- argument to func on event.
- **
- ** Returns:
- ** none.
- **
- ** Side Effects:
- ** none.
- */
-
- EVENT *
- setevent(intvl, func, arg)
- time_t intvl;
- int (*func)();
- int arg;
- {
- register EVENT **evp;
- register EVENT *ev;
- auto time_t now;
- extern tick();
-
- if (intvl <= 0)
- {
- syserr("setevent: intvl=%ld\n", intvl);
- return (NULL);
- }
-
- (void) time(&now);
-
- /* search event queue for correct position */
- for (evp = &EventQueue; (ev = *evp) != NULL; evp = &ev->ev_link)
- {
- if (ev->ev_time >= now + intvl)
- break;
- }
-
- /* insert new event */
- ev = (EVENT *) xalloc(sizeof *ev);
- ev->ev_time = now + intvl;
- ev->ev_func = func;
- ev->ev_arg = arg;
- ev->ev_pid = getpid();
- ev->ev_link = *evp;
- *evp = ev;
-
- if (tTd(5, 5))
- printf("setevent: intvl=%ld, for=%ld, func=%x, arg=%d, ev=%x\n",
- intvl, now + intvl, func, arg, ev);
-
- tick();
- return (ev);
- }
- /*
- ** CLREVENT -- remove an event from the event queue.
- **
- ** Parameters:
- ** ev -- pointer to event to remove.
- **
- ** Returns:
- ** none.
- **
- ** Side Effects:
- ** arranges for event ev to not happen.
- */
-
- clrevent(ev)
- register EVENT *ev;
- {
- register EVENT **evp;
-
- if (tTd(5, 5))
- printf("clrevent: ev=%x\n", ev);
- if (ev == NULL)
- return;
-
- /* find the parent event */
- (void) signal(SIGALRM, SIG_IGN);
- for (evp = &EventQueue; *evp != NULL; evp = &(*evp)->ev_link)
- {
- if (*evp == ev)
- break;
- }
-
- /* now remove it */
- if (*evp != NULL)
- {
- *evp = ev->ev_link;
- free((char *) ev);
- }
-
- /* restore clocks and pick up anything spare */
- tick();
- }
- /*
- ** TICK -- take a clock tick
- **
- ** Called by the alarm clock. This routine runs events as needed.
- **
- ** Parameters:
- ** none.
- **
- ** Returns:
- ** none.
- **
- ** Side Effects:
- ** calls the next function in EventQueue.
- */
-
- tick()
- {
- register time_t now;
- register EVENT *ev;
- int mypid = getpid();
-
- (void) signal(SIGALRM, SIG_IGN);
- (void) alarm(0);
- now = curtime();
-
- if (tTd(5, 4))
- printf("tick: now=%ld\n", now);
-
- while ((ev = EventQueue) != NULL &&
- (ev->ev_time <= now || ev->ev_pid != mypid))
- {
- int (*f)();
- int arg;
- int pid;
-
- /* process the event on the top of the queue */
- ev = EventQueue;
- EventQueue = EventQueue->ev_link;
- if (tTd(5, 6))
- printf("tick: ev=%x, func=%x, arg=%d, pid=%d\n", ev,
- ev->ev_func, ev->ev_arg, ev->ev_pid);
-
- /* we must be careful in here because ev_func may not return */
- (void) signal(SIGALRM, tick);
- #ifdef SIGVTALRM
- /* reset 4.2bsd signal mask to allow future alarms */
- (void) sigsetmask(sigblock(0) & ~sigmask(SIGALRM));
- #endif SIGVTALRM
-
- f = ev->ev_func;
- arg = ev->ev_arg;
- pid = ev->ev_pid;
- free((char *) ev);
- if (pid != getpid())
- continue;
- if (EventQueue != NULL)
- {
- if (EventQueue->ev_time > now)
- (void) alarm((unsigned) (EventQueue->ev_time - now));
- else
- (void) alarm(3);
- }
- (*f)(arg);
- (void) alarm(0);
- now = curtime();
- }
- (void) signal(SIGALRM, tick);
- if (EventQueue != NULL)
- (void) alarm((unsigned) (EventQueue->ev_time - now));
- }
- /*
- ** SLEEP -- a version of sleep that works with this stuff
- **
- ** Because sleep uses the alarm facility, I must reimplement
- ** it here.
- **
- ** Parameters:
- ** intvl -- time to sleep.
- **
- ** Returns:
- ** none.
- **
- ** Side Effects:
- ** waits for intvl time. However, other events can
- ** be run during that interval.
- */
-
- static bool SleepDone;
-
- sleep(intvl)
- unsigned int intvl;
- {
- extern endsleep();
-
- if (intvl == 0)
- return;
- SleepDone = FALSE;
- (void) setevent((time_t) intvl, endsleep, 0);
- while (!SleepDone)
- pause();
- }
-
- static
- endsleep()
- {
- SleepDone = TRUE;
- }
- @
-
-
- 5.8.0.1
- log
- @Added static declaration for endsleep() to make gcc happy.
- @
- text
- @d221 1
- a221 1
- static endsleep();
- @
-
-
- 5.8.0.2
- log
- @Shifted position of #include "sendmail.h" to avoid SIGCHLD re-definition
- warning on System 5 platforms.
- @
- text
- @d25 1
- a26 1
- # include "sendmail.h"
- a217 3
- #ifdef hpux
- unsigned int
- #endif /* hpux */
- @
-
-
- 5.8.0.3
- log
- @Replaced #ifdef hpux with the more generic #ifdef XPG3 (X-Open portability
- guide #3). From Andy Linton (andy.linton@@comp.vuw.ac.nz).
- @
- text
- @d218 1
- a218 1
- #ifdef XPG3
- d220 1
- a220 1
- #endif /* XPG3 */
- @
-
-
- 5.8.0.4
- log
- @Fixed forward declaration of endsleep().
- @
- text
- @d25 2
- a26 2
- #include <signal.h>
- #include "sendmail.h"
- d176 1
- a176 1
- #endif /* SIGVTALRM */
- a216 1
- void endsleep();
- d224 2
- d234 1
- a234 1
- static void
- @
-
-
- 5.8.0.5
- log
- @Declare tick() to be SIG_TYPE.
- @
- text
- @a27 2
- SIG_TYPE tick();
-
- d55 1
- a143 1
- SIG_TYPE
- @
-
-
- 5.8.0.6
- log
- @Deleted #include <sys/types.h> as it's already included via sendmail.h from
- useful.h. #include "sendmail.h" relocated to top of #include list.
- @
- text
- @d25 1
- a26 1
- #include <signal.h>
- @
-
-
- 5.8.0.7
- log
- @Added static keyword to tick() declaration.
- @
- text
- @d28 1
- a28 1
- static SIG_TYPE tick();
- d145 1
- a145 1
- static SIG_TYPE
- @
-
-
- 5.8.0.8
- log
- @ANSIfied.
- @
- text
- @d28 1
- a28 2
- static void tick();
- static void endsleep();
- d51 1
- a51 1
- void (*func)();
- a101 1
- void
- d145 1
- a145 1
- static void
- d162 1
- a162 1
- void (*f)();
- d202 1
- a202 1
- ** XSLEEP -- a version of sleep that works with this stuff
- d219 1
- d221 4
- a224 2
- void
- Xsleep(intvl)
- @
-
-
- 5.8.0.9
- log
- @Include <sys/signal.h>, not <signal.h>.
- @
- text
- @d26 1
- a26 1
- #include <sys/signal.h>
- d28 1
- a28 1
- static SIG_TYPE tick();
- d147 1
- a147 1
- static SIG_TYPE
- @
-
-
- 5.8.0.10
- log
- @Added RCS ID string
- @
- text
- @a22 1
- static char rcsid[] = "@@(#)$Id$";
- @
-
-
- 5.8.0.11
- log
- @Now uses TIME_TYPE for time() arguments.
- @
- text
- @d23 1
- a23 1
- static char rcsid[] = "@@(#)$Id: clock.c,v 5.8.0.10 1991/04/05 14:55:15 paul Exp paul $";
- d58 1
- a58 1
- auto TIME_TYPE now;
- d71 1
- a71 1
- if (ev->ev_time >= (time_t)now + intvl)
- d77 1
- a77 1
- ev->ev_time = (time_t)now + intvl;
- d86 1
- a86 1
- intvl, (time_t)now + intvl, func, arg, ev);
- @
-
-
- 5.8.0.12
- log
- @Use sigprocmask if LACK_SIGBLOCK is defined.
- @
- text
- @d23 1
- a23 1
- static char rcsid[] = "@@(#)$Id: clock.c,v 5.8.0.11 1991/05/18 17:20:31 paul Exp paul $";
- a179 9
- # ifdef LACK_SIGBLOCK
- {
- sigset_t set = SIGALRM;
- (void) sigprocmask(SIG_UNBLOCK, &set, NULL);
- }
- # else /* !LACK_SIGBLOCK */
- # ifndef sigmask
- # define sigmask(m) (1<<((m)-1))
- # endif /* !sigmask */
- a180 1
- # endif /* LACK_SIGBLOCK */
- @
-
-
- 5.8.0.13
- log
- @Use TIME_TYPE instead of time_t.
- @
- text
- @d23 1
- a23 1
- static char rcsid[] = "@@(#)$Id: clock.c,v 5.8.0.12 1991/05/30 22:11:12 paul Exp paul $";
- d52 1
- a52 1
- TIME_TYPE intvl;
- d71 1
- a71 1
- if (ev->ev_time >= (TIME_TYPE)now + intvl)
- d77 1
- a77 1
- ev->ev_time = (TIME_TYPE)now + intvl;
- d86 1
- a86 1
- intvl, (TIME_TYPE)now + intvl, func, arg, ev);
- d88 1
- a88 1
- (void) tick();
- d131 1
- a131 1
- (void) tick();
- d151 1
- a151 1
- register TIME_TYPE now;
- a212 5
- #ifdef notdef
- #if ( SIG_TYPE == int )
- return(0);
- #endif /* SIG_TYPE == int */
- #endif /* notdef */
- d240 1
- a240 1
- (void) setevent((TIME_TYPE) intvl, endsleep, 0);
- @
-